﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Serialization;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Storage;


namespace Tiro_Alvo.Core
{
   /// <summary>
    /// Exrtaido de http://xnaessentials.com/tutorials/highscores.aspx
   /// </summary>
    [Serializable]
    public struct HighScoreData
    {
         #region "Variaveis" 
    /// <summary>
    /// Variaveis usasdas para armazenar o High Score, nome do jogador e o level que ele chegou
    /// </summary>
        public string[] playerName;
        public int[] score;
        public int[] level;

        public int Count;
         #endregion

        public HighScoreData(int count)
        {
            playerName = new string[count];
            score = new int[count];
            level = new int[count];

            Count = count;
        }
        #region "Valores"
        /// <summary>
        /// Salva e Carrega os HighScores e os Nomes
        /// </summary>
        /// <param name="data"></param>
        /// <param name="fileName">nome do arquivo que ira conter os highScores</param>
        public static void saveHighScore(HighScoreData data, string fileName)
        {
            //get do caminho para o save game
            string fullPath = Path.Combine(fileName);

            //abre o arquivo, o criando se nescessario
            FileStream stream = File.Open(fullPath, FileMode.OpenOrCreate);

            try
            {
                //converte os dados dos objetos em XML
                XmlSerializer serializer = new XmlSerializer(typeof(HighScoreData));
                serializer.Serialize(stream, data);

            }

            finally
            { 
                //fecha o arquivo
                stream.Close();
            }
        }

        #endregion

       /* public static(HighScoreData LoadHighScore(string filename)
        {
            HighScoreData data;


        
        }*/
    }

    }
   

   
